package com.haiqiu.system.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.haiqiu.common.controller.BaseController;
import com.haiqiu.common.page.PageRequest;
import com.haiqiu.common.result.Constants;
import com.haiqiu.common.result.ResultData;
import com.haiqiu.system.entity.SysLoginLog;
import com.haiqiu.system.service.SysLoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

/**
 * @author HaiQiu
 * @ClassName MailController.java
 * @Description 登录日志管理
 * @createTime 2021年08月04日
 */
@Api(tags = "登录日志管理",description = "登录日志接口操作")
@RestController
@RequestMapping("/login/log")
public class LoginLogController extends BaseController {


    @Autowired
    private SysLoginLogService sysLoginLogService;


    @ApiOperation(value = "登录日志批量删除",notes = "批量删除登录日志的操作")
    @DeleteMapping("")
    public ResultData delete(@ApiParam(value = "日志ID，数组[]") @RequestBody Set<Long> ids){
        return decide(Constants.DELETE, sysLoginLogService.delete(ids));
    }

    @ApiOperation(value = "登录日志分页",notes = "模糊分页登录日志的操作")
    @PostMapping("/list")
    public ResultData list(@ApiParam(value = "模糊分页登录日志") @RequestBody PageRequest<SysLoginLog> request){
        return decide(sysLoginLogService.list(request));
    }


    @ApiOperation(value = "登录查询单条",notes = "查询单条登录日志的操作")
    @GetMapping("")
    public ResultData get(@ApiParam(value = "数据ID") @RequestParam Long id){
        return decide(sysLoginLogService.get(id));
    }

    @ApiOperation(value = "登录日志查询所有",notes = "查询所有登录日志的操作")
    @GetMapping("/all")
    public ResultData all(){
        return decide(sysLoginLogService.all());
    }
}
